home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 November
/
PCWorld_2006-11_cd.bin
/
domacnost a kancelar
/
findgraph
/
fgraph.exe
/
{app}
/
TestVC
/
CoolMenu.h
< prev
next >
Wrap
C/C++ Source or Header
|
2002-11-20
|
3KB
|
85 lines
////////////////////////////////////////////////////////////////
// OwnerDraw Menu
// 1998 Microsoft Systems Journal.
// from DiLascia Coolmenu\MBTest\CoolMenu.cpp
// 1. add 'CPtrList m_menuItems' to remove memory leaks
// 2. Remove accelerator
// 3. Remove WM_CHAR
// 4. Get image in bitmap from m_wndToolBar
// 5. For IdButn = ID_FILE_OPEN add Popup menu IDR_FILEDROPDOWN
//////////////////
//---------------------------------------------------------------------------------------------
//
#include "SubClass.h"
//////////////////
// CCoolMenuManager implements "cool" menus with buttons in them. To use:
//
// * Instantiate in your CMainFrame.
// * Call Install to install it
// * Call LoadToolbars or LoadToolbar to load toolbars
//
// Don't forget to link with CoolMenu.cpp, Subclass.cpp and DrawTool.cpp!
//
class CCoolMenuManager : private CSubclassWnd {
public:
DECLARE_DYNAMIC(CCoolMenuManager)
CCoolMenuManager();
~CCoolMenuManager();
// public functions to use
void Install(CFrameWnd* pFrame, CToolBar *pToolBar); // connect to main frame
// add drop_down button (now only ID_FILE_OPEN)
void AddDropDown(UINT idButton, UINT idMenu, UINT uFlags=TPM_RIGHTBUTTON);
// should never need to call:
virtual void Destroy(); // destroys everything--to re-load new toolbars?
protected:
CFrameWnd* m_pFrame; // frame window I belong to
CToolBar * m_pToolBar; // use only 1 toolbar
CFont m_fontMenu; // menu font
CSize m_szButton; // size of button (including shadow)
CPtrList m_menuList; // list of HMENU's initialized
CPtrList m_menuItems; // list of CMyItemData
CMapWordToPtr m_dropButns; // list of buttons with drop down (idButton, idMenu)
// helpers
CFont* GetMenuFont();
void DrawMenuText(CDC& dc, CRect rc, CString text, COLORREF color);
BOOL Draw3DCheckmark(CDC& dc, const CRect& rc, BOOL bSelected,
HBITMAP hbmCheck=NULL);
void DrawButton(CDC& dc, int iButton, CPoint p, BOOL bEnabled);
void ConvertMenu(CMenu* pMenu,UINT nIndex,BOOL bSysMenu,BOOL bShowButtons);
// window proc to hook frame using CSubclassWnd implementation
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
// CSubclassWnd message handlers
virtual void OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu);
virtual BOOL OnMeasureItem(LPMEASUREITEMSTRUCT lpms);
virtual BOOL OnDrawItem(LPDRAWITEMSTRUCT lpds);
virtual void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
virtual BOOL OnNotify(UINT msg, WPARAM wParam, LPARAM lParam);
void OnFiledropdown(UINT nIdButn);
};
//////////////////
// Friendly version of MENUITEMINFO initializes itself
//
struct CMenuItemInfo : public MENUITEMINFO {
CMenuItemInfo()
{ memset(this, 0, sizeof(MENUITEMINFO));
cbSize = sizeof(MENUITEMINFO);
}
};